<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/pages/commons/path.jsp"%>

<script type="text/javascript">
	function isValid() {
		$('#id').validatebox({
			required : true,
			missingMessage : '请输入有效的分类编号！'
		});
		if (!$('#id').validatebox('isValid'))
			return false;
		$('#className').validatebox({
			required : true,
			missingMessage : '请输入有效的分类名称！'
		});
		if (!$('#className').validatebox('isValid'))
			return false;
		$('#pid').validatebox({
			required : true,
			missingMessage : '请输入有效的父id！'
		});
		if (!$('#pid').validatebox('isValid'))
			return false;
		$('#dbId').validatebox({
			required : true,
			missingMessage : '请输入有效的所属数据库！'
		});
		if (!$('#dbId').validatebox('isValid'))
			return false;
		$('#classPackage').validatebox({
			required : true,
			missingMessage : '请输入有效的数据库包！'
		});
		if (!$('#classPackage').validatebox('isValid'))
			return false;
		$('#urlPath').validatebox({
			required : true,
			missingMessage : '请输入有效的！'
		});
		if (!$('#urlPath').validatebox('isValid'))
			return false;

		return true;
	}

	function save() {
		if (!isValid())
			return;
			var id = $.trim($('#id').val());
			var className = $.trim($('#className').val());
			var pid = $.trim($('#pid').val());
			var dbId = $.trim($('#dbId').val());
			var classPackage = $.trim($('#classPackage').val());
			var urlPath = $.trim($('#urlPath').val());

		$.ajax({
			type : 'post',
			url : '${ctx}/adminManage/sys/autoDbClass/doUpdate.do',
			data : {
					id : id,
					className : className,
					pid : pid,
					dbId : dbId,
					classPackage : classPackage,
					urlPath : urlPath
			},
			dataType : 'json',
			success : function(data) {
				var result = data.result;
				if (result == 'success') {
					$.messager.alert('提示', '操作成功！', 'info');

					$('#editDiv').dialog('close');
					$('#dataTable').treegrid('reload');
					$('#dataTable').treegrid('clearChecked');
				} else {
					$.messager.alert('提示', '操作失败！<br />' + data.error, 'error');
				}
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				$.messager.alert('提示', '操作失败！<br />' + errorThrown, 'error');
			}
		});
	}
	
	function cancel() {
		$('#editDiv').dialog('close');
	}
</script>

<table class="table2">
	<tr>
		<td>分类编号：</td>
		<td>
			<input id="id" type="text" value="${info.id}" style="width: 200px" />
		</td>
	</tr>
	<tr>
		<td>分类名称：</td>
		<td>
			<input id="className" type="text" value="${info.className}" style="width: 200px" />
		</td>
	</tr>
	<tr>
		<td>父id：</td>
		<td>
			<input id="pid" type="text" value="${info.pid}" style="width: 200px" />
		</td>
	</tr>
	<tr>
		<td>所属数据库：</td>
		<td>
			<input id="dbId" type="text" value="${info.dbId}" style="width: 200px" />
		</td>
	</tr>
	<tr>
		<td>数据库包：</td>
		<td>
			<input id="classPackage" type="text" value="${info.classPackage}" style="width: 200px" />
		</td>
	</tr>
	<tr>
		<td>：</td>
		<td>
			<input id="urlPath" type="text" value="${info.urlPath}" style="width: 200px" />
		</td>
	</tr>
	<tr>
		<td colspan="2" align="center">
			<a id="saveButton" class="easyui-linkbutton" icon="icon-ok" onclick="save()">确定</a>
			<a class="easyui-linkbutton" icon="icon-cancel" onclick="cancel()">取消</a>
		</td>
	</tr>
</table>